package com.wd.elec.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @className: DateTimeUtil
 * @description: TODO 类描述
 * @author: liumingkun
 * @date: 2024/7/26
 **/
public class DateTimeUtil {

    private final static String YYYY_MM_DD_HH_MM_SS ="yyyy-MM-dd HH:mm:ss";

    public static String getTime(int hour){
        Calendar calendar=Calendar.getInstance();
        calendar.set(2025,0,1,hour,0,0);
        SimpleDateFormat dateFormat=new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        return  dateFormat.format(calendar.getTime());
    }

    public static String getTime(Date date, int hour)
    {
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR,hour);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        calendar.set(Calendar.MILLISECOND,0);
        SimpleDateFormat dateFormat=new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        return dateFormat.format(calendar.getTime());
    }


    public static void main(String[] args) {
        System.out.println(getTime(1));
    }
}
